/**
 * Copyright (c) 2010 icer He <icerhe@gmail.com>
 */
package com.icerhe.trigger;


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.SystemClock;
import android.util.Log;
import android.widget.Toast;

/**
 * @author icer
 *
 */
public class TaskReceiver extends BroadcastReceiver {
	/* (non-Javadoc)
	 * @see android.content.BroadcastReceiver#onReceive(android.content.Context, android.content.Intent)
	 */
	@Override
	public void onReceive(Context context, Intent intent) {
		Log.d(Consts.TAG, "TaskReceiver start");
		
		Boolean runTask = intent.getBooleanExtra(TaskHelper.RUN_TASK, false);
		
		if (runTask) {
			//启动服务
			Intent it = new Intent(context, CronTaskService.class);
		    context.startService(it);	
		}

		//设置下一次触发
		TaskHelper.setNextTask(context);
		Log.d(Consts.TAG, "TaskReceiver over");
		
	}

}
